#ifndef COMM_RINNAI_H
#define COMM_RINNAI_H

//#include <stdint.h>
#include "sc95f.h"

#define FRY_SHORT 		 0x01
#define SELF_HELP_SHORT	 0x02
#define TIMING_SHORT	 0x04
#define WIND_SPEED_SHORT 0x08
#define INCREASE_SHORT   0x20
#define DECREASE_SHORT   0x10

#define FRY_LONG 		 0x01
#define SELF_HELP_LONG 	 0x02
#define TIMING_LONG 	 0x04
#define WIND_SPEED_LONG  0x08
#define INCREASE_LONG    0x20
#define DECREASE_LONG    0x10



#define TX_BUF_SIZE 18
#define RX_BUF_SIZE 21

#define version    0x13

extern uint8_t	  Aip33624_diffuse_display_flg;
extern uint8_t 		Aip33624_diffuse_one_display_flg;
extern uint8_t 		Aip33624_ring_auto_show_flg;
extern uint8_t 		Aip33624_ring_auto_one_show_flg;
extern uint8_t 		Aip33624_breath_led_control_flg;
extern uint8_t 		Aip33624_ring_auto_one_show_end_flg;

extern uint8_t tran_lent;
extern uint8_t tran_com_end;
extern uint8_t tran_com_wait_flg;

extern uint8_t button_long_flg;
extern uint8_t tx_count1;

extern uint8_t Digital_tubes_show_time_interval;
extern uint8_t Digital_tubes_show_time_interval_flg;

extern uint8_t button_tran_buff;
extern uint8_t button_tab_num;

union transmit_data_union
{
   uint8_t tx_buffer[TX_BUF_SIZE];
	 struct
	 {
		uint8_t Frame_header;
		uint8_t Machine_type;
		uint8_t Data_length;
		uint8_t Command_id;
		uint8_t Data_buff[13];
		uint8_t Checkout;

	 }tran_data;
};

union receive_data_union
{
  uint8_t rx_buffer[RX_BUF_SIZE];
 struct
 {
  uint8_t Frame_header;
  uint8_t Machine_type;
  uint8_t Data_length;
  uint8_t Command_id;
  uint8_t Data_buff[16];
  uint8_t Checkout;

 }receive_data;
};

extern union transmit_data_union  tran_data;
extern union receive_data_union   rec_data;
extern uint8_t rx_count ;
extern uint8_t	rx_buff[21];
extern uint8_t	rx_buff1[21];
extern uint8_t	rx_buff_old[21];
//extern uint8_t comm_tran_over_flg;
extern uint8_t uart_wait_time_count;
extern uint8_t uart_wait_time;
extern uint8_t uart_wait_err_flg;
extern uint8_t rx_end_flg;
extern uint8_t rx_check;
extern uint8_t tx_check;


extern uint8_t tx_buff_err;
extern uint8_t tx_buff_err_count;

 uint8_t TX_CheckSum(uint8_t *buf, uint8_t len);
 uint8_t RX_CheckSum(uint8_t *buf, uint8_t len);



void comm_process(void);
void comm_auto_tran(void);
void comm_custom_tran(uint8_t tab_num,uint8_t value);
void rec_detection(void);
void comm_err_detection2(void);
 uint8_t s_bit_change(uint8_t rxbuff);
 void Digital_tubes_upgrate(void);
 void uart_reset(void);
 
#endif
